//
//  FWFriendService.m
//  BirdLoveSheep
//
//  Created by wwj on 16/3/9.
//  Copyright © 2016年 wwj. All rights reserved.
//

#import "FWAttentService.h"
#import "FWHttpUtil.h"
#import <MJExtension.h>
#import "FWTypeModel.h"
#import <SVProgressHUD.h>
#import "FWTagsModel.h"

@implementation FWAttentService

+ (NSURLSessionDataTask *)getTypeDataWith:(FWTypeRequest *)request success:(void (^)(FWTypeResponse *))success failure:(void (^)(NSError *))failure{
    [SVProgressHUD showWithStatus:@"加载中"];
     return [FWHttpUtil getWithURL:KBaseURL params:request.mj_keyValues success:^(id responseObject) {
        [SVProgressHUD dismiss];
        if (success) {
            FWTypeResponse *data = [FWTypeResponse mj_objectWithKeyValues:responseObject];
            success(data);
        }
    } failure:^(NSError *error) {
        [SVProgressHUD dismiss];
        if (failure) {
            failure(error);
        }
    }];
}

+ (NSURLSessionDataTask *)getUserDataWith:(FWUserRequest *)request success:(void (^)(FWUserResponse *))success failure:(void (^)(NSError *))failure{
    return [FWHttpUtil getWithURL:KBaseURL params:request.mj_keyValues success:^(id responseObject) {
        if (success) {
            FWUserResponse *data = [FWUserResponse mj_objectWithKeyValues:responseObject];
            success(data);
        }
    } failure:^(NSError *error) {
        if (failure) {
            failure(error);
        }
    }];
}

+ (NSURLSessionDataTask *)getTagsOrdeDataWith:(FWTagsRequest *)request success:(void (^)(NSArray *))success failure:(void (^)(NSError *))failure{
    [SVProgressHUD setDefaultMaskType:SVProgressHUDMaskTypeClear];
    [SVProgressHUD showWithStatus:@"加载中..."];
    return [FWHttpUtil getWithURL:KBaseURL params:request.mj_keyValues success:^(id responseObject) {
        [SVProgressHUD dismiss];
        if (success) {
            success([FWTagsModel mj_objectArrayWithKeyValuesArray:responseObject]);
        }
    } failure:^(NSError *error) {
        [SVProgressHUD dismiss];
        if (failure) {
            failure(error);
        }
    }];
}
@end
